<template>
  <div>
    <div class="aui-content aui-margin-b-15">
      <auth-form @submit="login" @changeType="changeType" :form_data="form_data" :form_item="form_item"></auth-form>
    </div>
  </div>
</template>

<script>
import{ actionTypes} from '@/store/modules/auth'
import authForm from '@/components/AuthForm.vue'
export default {
  components:{
    authForm
  },
  data(){
    return{
      form_data:{},
      form_item:[
        {
          icon:'paper',
          placeholder:'输入邮箱',
          prop:'email',
          type:'text'
        },
        {
          icon:'lock',
          placeholder:'输入密码',
          prop:'password',
          type:'password'
        }
      ]
    }
  },
  methods:{
    changeType(index){
      var type = this.form_item[index].type;
      type=type=='password'?'text':'password'
      this.form_item[index].type = type;
    },
    login(){
      this.$store.dispatch(actionTypes.login,this.form_data).then(res=>{
        console.log(res)
        this.$router.replace('/home')
      })
    }
  }
};
</script>

<style>
</style>